import {ListDetailPageStackPaginationStore} from "./ListDetailPageStackStore";
import {ProcurementDetail, QueryProcurementResponse} from "../apis/ProcurementApi";

const procurementPageStackStore = new ListDetailPageStackPaginationStore<QueryProcurementResponse, ProcurementDetail, number>(
    detail => ({
        id: detail.id,
        createdDateTime: detail.createdDateTime,
        createdBy: detail.createdBy,
        lastModifiedDateTime: detail.createdDateTime,
        goodsKindAmount: detail.items.length,
        supplier: detail.supplier,
        status: (() => {
            if (!detail.submittedDateTime) {
                return "WAIT_SUBMIT"
            } else if (!detail.receiptDateTime) {
                return "SUBMITTED"
            } else {
                return "RECEIPT"
            }
        })(),
    }),
    item => item.id,
    detail => detail.id,
)

export default procurementPageStackStore